package com.lwgk.mvp.view;

import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lwgk.R;
import com.lwgk.basic.BasicBelowActionBarActivity;
import com.lwgk.compinterface.OnMultiClickListener;
import com.lwgk.mvp.model.SplashSmoothPlatePresent;
import com.lwgk.mvp.presenter.SplashSmoothPlatePresentImpl;
import com.lwgk.mvp.presenter.SplashSmoothPlateView;
import com.lwgk.widget.SmoothPlateBanner;

import java.util.ArrayList;
import java.util.List;

/**
 * created by 赵航
 * 联系微信 微信号：zhao--hang--
 * on 2019/7/12
 * --------------------------------------------------------------------------
 * 描述：所有包含沉寝式状态的基类，页面可以沉寝到状态栏下面
 * 注意事项：目前状态下的透明度为100%
 */
public class SplashSmoothPlateActivity extends BasicBelowActionBarActivity implements SplashSmoothPlateView {

    private ViewPager                    mViewPager;
    private List<Integer>                mList = new ArrayList<>();
    private SplashSmoothPlatePresentImpl mPresent;
    private TextView                     mEnterButton;
    private SmoothPlateBanner            mSmoothPlateBanner;

    @Override
    protected int setContentSuccessView() {
        return R.layout.activity_splash_smooth_plate;
    }

    @Override
    protected void initView() {
        mViewPager = (ViewPager) findViewById(R.id.viewPager);
        mEnterButton = (TextView) findViewById(R.id.smooth_plate_button);
        mSmoothPlateBanner = (SmoothPlateBanner) findViewById(R.id.smooth_plate_banner);
    }

    @Override
    protected void initData() {

        mList.add(R.mipmap.ic_launcher);
        mList.add(R.mipmap.banner_two_img);
        mList.add(R.mipmap.banner_three_img);
        mList.add(R.mipmap.banner_four_img);
        //创建关联
        mPresent = new SplashSmoothPlatePresent(SplashSmoothPlateActivity.this);

        //处理数据
        mPresent.dealMoothhPlateData(mSmoothPlateBanner, mViewPager, mList, SplashSmoothPlateActivity.this);


        //设置图片滑动监听
        mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                mSmoothPlateBanner.getCurrentCount(position);
                if (position == mList.size() - 1) {
                    mSmoothPlateBanner.setVisibility(View.GONE);
                    mEnterButton.setVisibility(View.VISIBLE);
                } else {
                    mSmoothPlateBanner.setVisibility(View.VISIBLE);
                    mEnterButton.setVisibility(View.INVISIBLE);
                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        mEnterButton.setOnClickListener(new OnMultiClickListener() {
            @Override
            public void onMultiClick(View v) {
                //保存进来的数据
                mPresent.sevesMoothPlate();
                startActivity(new Intent(SplashSmoothPlateActivity.this,HomeActivity.class));
            }
        });
    }
}
